package GUI;

import java.awt.Image;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

public class Card{
	public enum Suit{
		SPADES("spade"), HEARTS("heart"), DIAMONDS("diamond"), CLUBS("club");
		private String name;
		private Suit(String name){
			this.name = name;
		}
		public String getSuitName(){
			return name;
		}
	}
	public enum Rank{
		Two("2", 2), Three("3", 3), Four("4", 4), Five("5", 5), Six("6", 6), Seven("7", 7), Eight("8", 8), Nine("9", 9), Ten("10", 10),
		Jack("J", 11), Queen("Q", 12), King("K", 13), Ace("A", 14);
		private String rank;
		private int val;
		private Rank(String rank, int val){
		this.rank = rank;
		this.val = val;
		}
		public String getRankName(){
			return rank;
		}
		public int getRank(){
			return val;
		}
	}
	private Suit suit;
	private Rank rank;
	public Card(Suit suit, Rank rank){
		this.suit = suit;
		this.rank = rank;
	}
	public Suit getSuit(){
		return suit;
	}
	public Rank getRank(){
		return rank;
	}
	public String getCardImagePath(){
		String name = suit.getSuitName() + "_" + rank.getRankName() + ".png";
		String path = Card.class.getResource("images/card_images/"+name).getPath();
		return path;
	}
	public Image getImage() throws IOException{
		Image img = ImageIO.read(new File(getCardImagePath()));
		return img;
	}
	public int getRankVal(){
		return rank.getRank();
	}
	public static Card faceDownCard(Card card){
		return new HiddenCard(card);
	}
}
